CREATE TABLE [dbo].[COMPRAS]
(
[ID] [numeric] (10, 0) NOT NULL,
[ID_CONDICION] [numeric] (10, 0) NOT NULL,
[TIPO] [bit] NOT NULL CONSTRAINT [DF_COMPRAS_TIPO] DEFAULT ((1)),
[ID_USUARIO] [numeric] (10, 0) NOT NULL,
[FECHA] [date] NOT NULL,
[F_VENCIMIENTO] [date] NOT NULL,
[ID_SUPLIDOR] [numeric] (10, 0) NOT NULL,
[NRO_FACTURA] [varchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[NCF] [varchar] (19) COLLATE SQL_Latin1_General_CP1_CI_AS NULL CONSTRAINT [DF_COMPRAS_NCF] DEFAULT (''),
[OBSERVACIONES] [varchar] (150) COLLATE SQL_Latin1_General_CP1_CI_AS NULL CONSTRAINT [DF_COMPRAS_OBSERVACIONES] DEFAULT (''),
[ACTIVO] [bit] NOT NULL CONSTRAINT [DF_COMPRAS_ACTIVO] DEFAULT ((1)),
[T_IMPUESTO] [numeric] (10, 2) NOT NULL CONSTRAINT [DF_COMPRAS_T_IMPUESTO] DEFAULT ((0)),
[T_DESCUENTO] [numeric] (10, 2) NOT NULL CONSTRAINT [DF_COMPRAS_T_DESCUENTO] DEFAULT ((0)),
[M_TOTAL] [numeric] (10, 2) NOT NULL CONSTRAINT [DF_COMPRAS_M_TOTAL] DEFAULT ((0)),
[M_PAGADO] [numeric] (10, 2) NOT NULL CONSTRAINT [DF_COMPRAS_M_PAGADO] DEFAULT ((0))
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[COMPRAS] ADD CONSTRAINT [PK_COMPRAS_1] PRIMARY KEY CLUSTERED  ([ID]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_COMPRAS_1] ON [dbo].[COMPRAS] ([ACTIVO]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_COMPRAS_2] ON [dbo].[COMPRAS] ([F_VENCIMIENTO]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_COMPRAS] ON [dbo].[COMPRAS] ([FECHA]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_COMPRAS_4] ON [dbo].[COMPRAS] ([ID_SUPLIDOR]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_COMPRAS_5] ON [dbo].[COMPRAS] ([ID_USUARIO]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_COMPRAS_3] ON [dbo].[COMPRAS] ([NRO_FACTURA]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[COMPRAS] ADD CONSTRAINT [FK_COMPRAS_CONDICIONES] FOREIGN KEY ([ID_CONDICION]) REFERENCES [dbo].[CONDICIONES] ([ID])
GO
ALTER TABLE [dbo].[COMPRAS] ADD CONSTRAINT [FK_COMPRAS_SUPLIDORES] FOREIGN KEY ([ID_SUPLIDOR]) REFERENCES [dbo].[SUPLIDORES] ([ID])
GO
ALTER TABLE [dbo].[COMPRAS] ADD CONSTRAINT [FK_COMPRAS_USUARIOS] FOREIGN KEY ([ID_USUARIO]) REFERENCES [dbo].[USUARIOS] ([ID])
GO
